package com.liteng.shadow.core.http;

import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public class HttpRequestBuilder
{
  private String charset;
  private HttpMethod method;
  private String url;
  private Map<String, String> headers;
  private Map<String, String> params;
  
  public HttpRequestBuilder()
  {
    this.method = HttpMethod.GET;
    this.headers = new HashMap();
    this.params = new LinkedHashMap();
  }
  
  public String getCharset()
  {
    return this.charset;
  }
  
  public HttpRequestBuilder setCharset(String charset)
  {
    this.charset = charset;
    return this;
  }
  
  public HttpMethod getMethod()
  {
    return this.method;
  }
  
  public HttpRequestBuilder setMethod(HttpMethod method)
  {
    this.method = method;
    return this;
  }
  
  public String getUrl()
  {
    return this.url;
  }
  
  public HttpRequestBuilder setUrl(String url)
  {
    this.url = url;
    return this;
  }
  
  public Map<String, String> getHeaders()
  {
    return Collections.unmodifiableMap(this.headers);
  }
  
  public HttpRequestBuilder setHeaders(Map<String, String> headers)
  {
    this.headers = headers;
    return this;
  }
  
  public HttpRequestBuilder addHeader(String key, String value)
  {
    this.headers.put(key, value);
    return this;
  }
  
  public Map<String, String> getParams()
  {
    return Collections.unmodifiableMap(this.params);
  }
  
  public HttpRequestBuilder setParams(Map<String, String> params)
  {
    this.params = params;
    return this;
  }
  
  public HttpRequestBuilder addParam(String key, String value)
  {
    this.params.put(key, value);
    return this;
  }
}
